import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/common.less'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'qweather-icons/font/qweather-icons.css'
import ElTableInfiniteScroll from 'el-table-infinite-scroll'
import vue3SeamlessScroll from 'vue3-seamless-scroll'

// 解决报错: ResizeObserver loop completed with undelivered notifications.
// app.vue写在script里面  main.js写在app挂载完之后
  const debounce = (fn, delay) => {
    let timer
    return (...args) => {
      if (timer) {
        clearTimeout(timer)
      }
      timer = setTimeout(() => {
        fn(...args)
      }, delay)
    }
  }
    
  const _ResizeObserver = window.ResizeObserver;
  window.ResizeObserver = class ResizeObserver extends _ResizeObserver{
    constructor(callback) {
      callback = debounce(callback, 200);
      super(callback);
    }
  }
  // 解决报错: ResizeObserver loop completed with undelivered notifications.

  // window.onresize = function () {
  //   const _this = this;
  //   _this.height = document.body.clientHeight;
  //   document.documentElement.style.fontSize = 10 * _this.height/1080 + "px";
  //   store.commit('setHtmlScaleStore',parseFloat(_this.height/1080));
  // }
const app = createApp(App)
app.use(store).use(router)
app.use(ElementPlus)
app.use(ElTableInfiniteScroll)
app.use(vue3SeamlessScroll)
app.mount('#app')
